home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / lib / dial / d_assign.c next >
Encoding:
C/C++ Source or Header  |  1986-06-04  |  1.2 KB  |  84 lines

  1. #
  2. /*
  3.  *    D _ A S S I G N . C
  4.  *
  5.  *    Doug Kingston, BRL, 4 August 81
  6.  *
  7.  *    Takes the name of an assignable device as an argument.
  8.  *    The function calles the program /bin/assign to get a device
  9.  *    for exclusive use.
  10.  */
  11. #include "d_returns.h"
  12.  
  13. #ifdef DOASSIGN
  14. struct {
  15.     char lobyte;
  16.     char hibyte;
  17. };
  18.  
  19. extern    int    d_errno;
  20.  
  21. d_assign (devname)
  22. char *devname;
  23. {
  24.     int status;
  25.  
  26.     if ((status = d_tryfork()) == -1) {
  27.         d_log ("d_assign", "couldn't fork");
  28.         d_errno = D_FORKERR;
  29.         return( D_FATAL );
  30.     }
  31.  
  32.     if (status == 0) {
  33.         /* CHILD */
  34.         (void) close (1);
  35.         open ("/dev/null", 1);
  36.         execl ("/bin/assign", "mmdf-assign", devname, (char *)0);
  37.         exit (99);
  38.     }
  39.     else {
  40.         /* PARENT */
  41.         wait (&status);
  42.         return (status.hibyte == 0 ? D_OK : D_NO);
  43.     }
  44. }
  45.  
  46.  
  47. d_deassign (devname)
  48. char *devname;
  49. {
  50.     int status;
  51.  
  52.     if ((status = d_tryfork()) == -1) {
  53.         d_log ("d_deassign", "couldn't fork");
  54.         return( D_NO );
  55.     }
  56.  
  57.     if( status == 0 ) {
  58.         /* CHILD */
  59.         (void) close (1);
  60.         open ("/dev/null", 1);
  61.         execl ("/bin/assign", "mmdf-assign", "-", devname, (char *)0);
  62.         exit (99);
  63.     }
  64.     else {
  65.         /* PARENT */
  66.         wait (&status);
  67.         return (status.hibyte == 0 ? D_OK : D_NO);
  68.     }
  69. }
  70.  
  71. #else
  72.  
  73. /* Fake routine for systems without "assign" */
  74.  
  75. d_assign() {
  76.     return( D_OK );
  77. }
  78.  
  79. d_deassign() {
  80.     return( D_OK );
  81. }
  82.  
  83. #endif
  84.